<template>
	<view>
		<u-modal :asyncClose="true" :showCancelButton="true" confirmColor="#FFEA5404" cancelColor="#FF3D3A3A"
			cancelText="取消" @confirm="confirmComplate" @cancel="cancleComplate" :show="true" :title="title">
			<view class="slot-content confirmdialog-content">
				<view v-if="shielid.type ==1">
					<text class="title">举报内容违规</text>
					<u--textarea v-model="content" placeholder="请输入举报原因" confirmType="done" count
						maxlength="150"></u--textarea>
					<text class="sumnery">请如实填写举报原因，平台将于24小时内处理。</text>
				</view>
				<view v-else class="">
					<text class="title">屏蔽该用户</text>
					<text class="sumnery">屏蔽该用户后您将无法看到该用户发送的所有内容，确认屏蔽吗?</text>
				</view>
			</view>
		</u-modal>

	</view>
</template>

<script>
	const app = getApp();
	const util = require("@/utils/util.js");
	const network = require("@/manager/network-manager.js");
	const dialog = require("@/utils/dialog.js");
	export default {
		name: "shieldPanel",
		data() {
			return {
				content: '',
				title: ""
			};
		},
		props: {
			shielid: {
				type: Object,
				default: () => {
					return {
						type: 1
					}
				}
			}

		},
		mounted() {
			console.log(this.shielid)
			this.title = this.shielid.type == 1 ? '举报内容违规' : '屏蔽该用户'
		},
		methods: {
			cancleComplate() {
				this.$emit('cancleComplate')
			},
			confirmComplate() {
				console.log(this.shielid)
				// if (util.isLogin(getApp())) {
				if (this.shielid.type == 0) {
					var params = {
						"blockUserid": this.shielid.authorId,
						"createBy": app.getUserId()
					};
					var uri = app.globalData.config.interfaces.URL_BLACK_ADD;
					network.post(uri, params, 'json').then(res => {
						if (res.code == 200) {
							uni.showToast({
								title: '屏蔽成功',
								duration: 2000,
								icon: 'none'
							})

							// app.globalData.blackuser.push(this.shielid.authorId)
							this.$emit('cancleComplate')

						} else {
							uni.showToast({
								title: '屏蔽成功',
								duration: 2000,
								icon: 'none'
							})
							this.$emit('cancleComplate')
						}

					}).catch(res => {

						console.error(res);
					});
				} else {

					var params = {
						"conteng": this.content,
						"id": this.shielid.id,
					};
					if (this.content.length == 0 || this.content == '') {
						uni.showToast({
							title: '请输入举报内容',
							duration: 2000,
							icon: 'none'
						})
						this.cancleComplate()
						return
					}
					var uri = app.globalData.config.interfaces.URL_BLACK_REPORT;
					network.post(uri, params, 'json').then(res => {
						if (res.code == 200) {
							uni.showToast({
								title: '举报成功',
								duration: 2000,
								icon: 'none'
							})
							this.$emit('cancleComplate')
						} else {
							uni.showToast({
								title: '举报成功',
								duration: 2000,
								icon: 'none'
							})
							this.$emit('cancleComplate')

						}

					}).catch(res => {

						console.error(res);
					});
				}



				// } else {
				// 	util.jumpLogin(this.from)
				// }
			}
		}
	}
</script>

<style scoped lang="scss">
	u--textarea {
		width: 100%;
		margin-bottom: 30rpx;
	}

	::v-deep .u-modal__content {
		display: block;
	}

	::v-deep .u-popup__content {
		background-color: #ffffff !important;
	}

	::v-deep .u-transition {
		bottom: 120rpx;

	}

	::v-deep .uni-picker-view-content {
		background-color: #ffffff !important;
	}

	.confirmdialog-content {
		width: 600rpx;
	}

	.title {
		font-size: 28rpx;
		font-weight: 600;
		color: #000000;
		margin-bottom: 30rpx;
	}

	.sumnery {

		font-size: 24rpx;
		color: #3d3a3a;
		margin-top: 20rpx;
	}
</style>